﻿CREATE TABLE [dbo].[Task]
(
	[Id] INT NOT NULL PRIMARY KEY IDENTITY,
	[Summary] NVARCHAR(500) NOT NULL,
	[Description]  NVARCHAR(MAX) NULL,
	[AssignedId] INT NULL,
	[ReporterId] INT NOT NULL,
	[AddDate] DATETIME NOT NULL DEFAULT getdate(), 
	[UpdateDate] DATETIME NOT NULL DEFAULT getdate(), 
	[ProjectId] INT NOT NULL,
	[ComponentId] INT NULL,
	[DueDate] DATETIME NULL,
	[Status] INT NOT NULL, 
	[Priority] INT NOT NULL,
	CONSTRAINT [FK_Task_Project] FOREIGN KEY ([ProjectId]) REFERENCES [Project] ([Id]),
	CONSTRAINT [FK_Task_Assignee] FOREIGN KEY ([AssignedId]) REFERENCES [User] ([Id]),
	CONSTRAINT [FK_Task_Reporter] FOREIGN KEY ([AssignedId]) REFERENCES [User] ([Id]),
	CONSTRAINT [FK_Task_Component] FOREIGN KEY ([ComponentId]) REFERENCES [Component] ([Id])
)
